<%@ page language="java" 
         contentType="text/html; charset=windows-1256"
         pageEncoding="windows-1256"
         import="LoginUtil.*"
         import="java.sql.*"
   %>
 <%  UserBean currentUser = (UserBean) (session.getAttribute("currentSessionUser")); 
 	if(currentUser == null || currentUser.getType().compareToIgnoreCase("patient") != 0 || currentUser.getType().compareToIgnoreCase("admin") == 0)
 	{
 		response.sendRedirect("login.jsp");
 	}
 	
 	 Statement stmt = null;
 	 ResultSet rs = null;
 	Connection currentCon = null;
     
     String searchQuery =
           "select * from login where type=2";
			    
	   try 
	   {
	      //connect to DB 
	      currentCon = ConnectionManager.getConnection();
	      stmt=currentCon.createStatement();
	      rs = stmt.executeQuery(searchQuery);
	   }
	   catch(Exception e)
	   {
		   
	   }
 %>
   <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
   "http://www.w3.org/TR/html4/loose.dtd">

   <html>

      <head>
         <meta http-equiv="Content-Type" 
            content="text/html; charset=windows-1256">
         <title>  Welcome - Adventure Time MedSys   </title>
         <link rel="stylesheet" type="text/css" href="style.css" />
         
         <script language="javascript" type="text/javascript" src="datetimepicker.js">

				//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
				//Script featured on JavaScript Kit (http://www.javascriptkit.com)
				//For this script, visit http://www.javascriptkit.com 

		</script>
      </head>
	
      <body>

         <center>
           <div class="h0"> Welcome <%= currentUser.getFirstName() + " " + currentUser.getLastName() %> </div>
           Not <%= currentUser.getFirstName()%>? <a href="login.jsp">Log in.</a><br><br></br>
           
           <div class="h1">Request an appointment below:</div>
           <FORM NAME="apptform" ACTION="RequestApptServlet" METHOD="GET">
           <table>
           	   <tr><input id="demo3" type="text" size="25"><a href="javascript:NewCal('demo3','ddmmmyyyy',true,24)">
           	   		<img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a><br>
           	   </tr>
	           <tr>Reason: <INPUT TYPE="text" NAME="reasonbox" VALUE=""></input></input><br>
	           		<br></tr>
	           <tr>Desired Doctor: <select name="doctordrop">
	           							<option value="null">select a doctor</option>
									    <%while (rs.next()){%>
									        <option value="<%= rs.getInt("id") %>">Dr. <%= rs.getString("firstname")%> <%= rs.getString("lastname")%></option>
									    <%}%>
									</select>
									 <br>
			 </tr>
			 
			 <tr><INPUT TYPE="submit" NAME="loginbutton" Value="Request Appointment"></tr>
	           
	           
           
           </table>
           </FORM>
           <br><br><br><br>
           
           <a href=""><div class="h1">View Medical History</div></a>
           
         </center>
         
         <%
         
         if (rs != null)	{
	         try {
	            rs.close();
	         } catch (Exception e) {}
	            rs = null;
	         }
		
	      if (stmt != null) {
	         try {
	            stmt.close();
	         } catch (Exception e) {}
	            stmt = null;
	         }
		
	      if (currentCon != null) {
	         try {
	            currentCon.close();
	         } catch (Exception e) {
	         }
	
	         currentCon = null;
	      }
         
         %>

      </body>
	
   </html>